{include file="public/header" /}
<script>
	$(function(){
		$('#create').click(function(){
			var load = layer.load();
			$.get("{:URL('Backup/add')}", function(data){
				layer.close(load);
				if(data.status == 1){
					layer.msg("数据备份成功", {icon: 1, time: 2000}, function(){
						window.location.reload();
					});
				}else{
					layer.msg("数据备份失败", {icon: 2, time: 2000});
				}
			},'json');
		})
		$('.backup').click(function(){
			var file = $(this).attr('data-file');
			layer.confirm('确认要还原吗？', function(index){
				var load = layer.load();
				$.get(
						"{:url('Backup/import')}",
						{file:file},
						function(data){
							layer.close(load);
							layer.msg(data.message, {icon: data.icon, time: 2000})
							if(data.status=='1'){
								setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
									window.location.reload();//页面刷新
								},2000)
							}
						},'json'
				);
			});
		})
		$('.clear').click(function(){
			layer.confirm('确认要清空数据吗？', function(index){
				var load = layer.load();
				$.get(
						"{:url('Backup/clear')}",
						function(data){
							layer.close(load);
							layer.msg(data.message, {icon: data.icon, time: 2000});

							if(data.status=='1'){
								setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
									window.location.reload();//页面刷新
								},2000)
							}
						},'json'
				);
			});
		})
		$('.delete').click(function(){
			var file = [$(this).attr('data-file')];
			del(file);
		})
		$('.deletes').click(function(){
			var files = tableCheck.getData();
			
			if(files==''){
				layer.msg('请选择要删除的文件'); return;
			}
			del(files);
		})
	})

	function del(file){

		layer.confirm('确认要删除吗？', function(index){
			$.get(
					"{:url('Backup/delete')}",
					{file: file},
					function(data){

						window.location.reload();
					}
			)
		})
	}
</script>
</head>
<body class="layui-anim">
<div class="x-nav layui-row">
	<span class="layui-breadcrumb layui-col-md9 layui-col-sm9">
		<a href="javascript:;">{$_page_navi.1.title}</a>
		<!-- {if $_page_navi.0}<a href="javascript:;">{$_page_navi.0.NavName}</a>{/if}
		{if $_page_navi.1}<a><cite>{$_page_navi.1.NavName}</cite></a>{/if} -->
	</span>
	<a class="layui-btn layui-btn-small" style="float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon">&#xe9aa;</i></a>
</div>
<div class="x-body">
	<!-- <blockquote class="layui-elem-quote layui-clear " style="padding: 5px;line-height: 38px;">
		<span style="font-size: 16px;"><i class="layui-icon">&#xe653;</i>&nbsp;{$_page_navi.1.NavName}</span>
		<form class="layui-form layui-col-md8 x-so layui-form-pane x-right" style="margin: 0;text-align: right;">
			<input class="layui-input date" placeholder="开始日" name="start_time" value="{$Request.param.start_time}"/>
			<input class="layui-input date" placeholder="截止日" name="end_time" value="{$Request.param.end_time}"/>
			<button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
		</form>
	</blockquote> -->
	<xblock>
		<button class="layui-btn layui-btn-danger deletes"><i class="layui-icon"></i>批量删除</button>
		<button class="layui-btn layui-btn-danger clear"><i class="layui-icon"></i>清空数据</button>
		<button class="layui-btn" id="create"><i class="layui-icon">&#xe61f;</i>备份</button>
		<span class="x-right" style="line-height:40px">共有数据：{:count($list)} 条</span>
	</xblock>
	<table class="layui-table layui-form">
		<thead>
		<tr>
			<th width="15"><input type="checkbox" lay-filter="list_all" lay-skin="primary"/></th>
			<th>文件名</th>
			<th>文件大小</th>
			<th>备份时间</th>
			<th>操作</th>
		</tr>
		</thead>
		<tbody>
		{volist name="list" id="v"}
		<tr class="data_line" data_id="{$v.file}">
			<td>{if $v.is_del}<input type="checkbox" lay-filter="list_checkbox" lay-skin="primary" value="{$v.file}"/>{/if}</td>
			<td>{$v.file}</td>
			<td>{$v.size}</td>
			<td>{:date('Y-m-d H:i:s',$v.create_time)}</td>
			<td class="td-manage">
				<div class="layui-btn-group">
					<a class="layui-btn layui-btn-sm backup" data-file="{$v.file}" href="javascript:;">还原</a>
					{if $v.is_del}<a class="layui-btn layui-btn-sm layui-btn-danger delete" data-file="{$v.file}">删除</a>{/if}
				</div>
			</td>
		</tr>
		{/volist}
		</tbody>
	</table>
</div>
</body>
</html>